package com.hamizhong.iflowers.interceptor;

import com.hamizhong.iflowers.utils.MyConstants;
import com.hamizhong.iflowers.web.base.MyBaseInterceptor;
import com.opensymphony.xwork2.ActionInvocation;

public class LoginInterceptor extends MyBaseInterceptor {

	@Override
	public String intercept(ActionInvocation actionInvocation) throws Exception {
		logger.info("-------------------- Hello LoginInterceptor ----------------------");
		
		if(getSSN().getAttribute(MyConstants.IFLOWERS_LOGIN_USER_VO) == null) {
			String requestURI = this.getRQ().getRequestURI();
			logger.info("---------LastRequestURI---------"+requestURI);
			getSSN().setAttribute(MyConstants.IFLOWERS_LOGIN_LAST_REQUEST_URI, requestURI);
			getSSN().setAttribute(MyConstants.IFLOWERS_LOGIN_LAST_REQUEST_URI_VALID_FLAG, MyConstants.IFLOWERS_LOGIN_LAST_REQUEST_URI_VALID_YES);
			
			return "loginInit";
		}else {
			return actionInvocation.invoke();
		}
		
	}

}
